#include<bits/stdc++.h>
using namespace std;

int main() {
  int T;
  cin>>T;
  while(T--){
    int n,s;
    cin>>n>>s;
    vector<int> v(n);
    bool flag = true;
    for(int i=0;i<n;i++){
      char num;
      cin>>num;
      v[i]=num-'0';
      if(i>=1&&v[i]!=v[i-1]){
        flag = false;
      }
    }
    if(flag){cout<<"0"<<endl;
    for(int i=0;i<n;i++){

    }
    }

    return 0;
  }
}



// 链接：https://ac.nowcoder.com/acm/contest/104637/C